<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 	<!-- 包含公共的JSP代码片段 -->
<title>无线点餐平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="${pageContext.request.contextPath }/backstage/detail/style/js/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/backstage/detail/style/js/page_common.js"></script>
<link href="${pageContext.request.contextPath }/backstage/detail/style/css/common_style_blue.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/backstage/detail/style/css/index_1.css" />
</head>
<script type="text/javascript">
	function update(node) { 
		if(node.innerHTML == "退桌"){
			if(confirm("您确定要退桌？") == false){ 
				return false; 
			} 
			else {
				return true;	
			}
		} else {
			if(confirm("您确定要预定？") == false){ 
				return false; 
			} 
			else {
				return true;	
			}
		}
	}
	
	function showPage(num){
		//1 修改隐藏域的值
		document.getElementById("pageNum").value = num;
		//2 提交表单
		document.forms[0].submit();
	}
</script>
<body>
<form action="${pageContext.request.contextPath }/dinnertable/findAll.do" method="post">
	<input type="hidden" name="pageNum" id="pageNum" value="1" />
</form>
<!-- 页面标题 -->
<div id="TitleArea">
	<div id="TitleArea_Head"></div>
	<div id="TitleArea_Title">
		<div id="TitleArea_Title_Content">
			<img border="0" width="13" height="13" src="${pageContext.request.contextPath }/backstage/detail/style/images/title_arrow.gif"/> 餐桌列表
		</div>
    </div>
	<div id="TitleArea_End"></div>
</div>


<!-- 过滤条件 -->
<div id="QueryArea">
	<form action="${pageContext.request.contextPath }/dinnertable/findAll.do" method="post">
		<input type="text" name="tablename" title="请输入餐桌名称">
		<input type="submit" value="搜索">
	</form>
</div>


<!-- 主内容区域（数据列表或表单显示） -->
<div id="MainArea">
    <table class="MainArea_Content" cellspacing="0" cellpadding="0">
        <!-- 表头-->
        <thead>
            <tr align="center" valign="middle" id="TableTitle">
				<td>编号</td>
				<td>桌名</td>
				<td>状态</td>
				<td>预定时间</td>
				<td>操作</td>
			</tr>
		</thead>	
		<!--显示数据列表 -->
        <tbody id="TableData">
			<c:forEach items="${pageBean.data }" var="dinnertableList">
				<tr class="TableDetail1">
					<td align="center">${dinnertableList.id }</td>
					<td align="center">${dinnertableList.tablename }</td>
					<td align="center">
						<c:if test="${dinnertableList.tablestatus == 0 }">空闲</c:if>
						<c:if test="${dinnertableList.tablestatus == 1 }">预订</c:if>
					</td>
					<td align="center">${dinnertableList.orderdate }</td>
					<td align="center">
						<a onClick="return update(this);" href="${pageContext.request.contextPath }/dinnertable/modify.do?id=${dinnertableList.id}&tablestatus=${dinnertableList.tablestatus }" onclick="javascript:return update()" class="FunctionButton" ><c:if test="${dinnertableList.tablestatus == 0 }">预定</c:if><c:if test="${dinnertableList.tablestatus == 1 }">退桌</c:if></a>
						<a href="${pageContext.request.contextPath }/dinnertable/remove.do?id=${dinnertableList.id}" onClick="return delConfirm();" class="FunctionButton">删除</a>				
					</td>
				</tr>
			</c:forEach>
        </tbody>
    </table>
	<table border="0" cellspacing="0" cellpadding="0" align="center">
		  <tr>
		    <td align="right">
		    	<span>第${pageBean.pageNum}/${pageBean.totalPage}页</span>
		        <span>
		        	<c:if test="${pageBean.pageNum > 1 }">
		            	<a href="javascript:void(0)" onclick="showPage(1)">[首页]</a>&nbsp;&nbsp;
		            	<a href="javascript:void(0)" onclick="showPage(${pageBean.pageNum - 1})">[上一页]</a>&nbsp;&nbsp;
		        	</c:if>
		        	
		        	<%--动态显示条 --%>
		        	<c:forEach begin="${pageBean.start }" end="${pageBean.end }" var="num">
		        		<a href="javascript:void(0)" onclick="showPage(${num})">${num}</a>&nbsp;&nbsp;
		        	</c:forEach>
		            
		            <c:if test="${pageBean.pageNum < pageBean.totalPage }">
		            	<a href="javascript:void(0)" onclick="showPage(${pageBean.pageNum + 1})">[下一页]</a>&nbsp;&nbsp;
		            	<a href="javascript:void(0)" onclick="showPage(${pageBean.totalPage})">[尾页]</a>&nbsp;&nbsp;
		        	</c:if>
		        </span>
		    </td>
		  </tr>
	</table>
   <!-- 其他功能超链接 -->
	<div id="TableTail" align="center">
		<div class="FunctionButton"><a href="${pageContext.request.contextPath }/backstage/detail/saveBoard.jsp">添加</a></div>
    </div> 
</div>
</body>
</html>